|
ARD2
1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
|
Driver for upcoming roll-over sensor. More...
#include "derivative.h"#include "utils.h"#include "Miranda.h"#include "DSPI.h"#include <limits.h>#include <stdlib.h>Functions | |
| uint8_t | u8fnMirandaReadRegister (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, uint16_t u16Register, uint16_t *pu16DataRead, const uint8_t cu8Protocol) |
| Reads one register from Miranda. | |
| uint8_t | u8fnMirandaWriteRegister (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, uint16_t u16Register, uint16_t u16ValueToWrite, uint16_t *pu16DataRead, const uint8_t cu8Protocol) |
| Writes to one register of the MMIRANDA. | |
| uint8_t | u8fnMirandaReset (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8Protocol) |
| Performs a soft-reset of the device. | |
| uint8_t | u8fnMirandaReadAccelRegisters (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8Protocol) |
| Reads accelerations by mean of registers readback. | |
| uint8_t | u8fnMirandaReadAllRegisters (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8Protocol) |
| Reads all registers content. | |
| uint8_t | u8fnMirandaReadAccelSPI (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint8_t cu8Axis, uint16_t *pu16AccelResults) |
| Reads acceleration by mean of SPI extraction (Protocol1 only) | |
| uint8_t | u8fnMirandaBatchOp (const uint8_t cu8DSPIInstance, const uint8_t cu8ChipSelect, const uint16_t *pu16DataToSend, uint16_t *pu16UnfilteredDataReceived, uint8_t u8Size, const uint8_t cu8Protocol) |
| Sends n transfers to the device, and reads-back as well. | |
| uint8_t | u8fnMirandaExtractRegisterResponse (const uint16_t *pu16RawResponse, uint16_t *pu16Response, uint8_t u8Size, const uint8_t cu8Protocol) |
| Extracts 8-bit information from raw data. | |
| uint8_t | u8fnMirandaExtractAccelResponse (const uint16_t *pu16RawResponse, uint16_t *pu16Response, uint8_t u8Size) |
| Extracts 10-bit accel information from raw data. | |
Variables | |
| const uint16_t | cau16MirandaReset [] |
| const uint16_t | cau16MirandaReadAllRegisters [] |
| const uint16_t | cau16MirandaPerformAccelReading [] |
| const uint16_t | cau16MirandaPerformAccelReadingSPI [] |
Driver for upcoming roll-over sensor.
Copyright (c) 2011 Freescale Semiconductor Freescale Confidential Proprietary
History:
| uint8_t u8fnMirandaBatchOp | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| const uint16_t * | pu16DataToSend, | ||
| uint16_t * | pu16UnfilteredDataReceived, | ||
| uint8_t | u8Size, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Sends n transfers to the device, and reads-back as well.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| pu16DataToSend,: | Pointer to complete message to send. Parity is calculated within the function. Constant tables in this file should be used accordingly. |
| pu16UnfilteredDataReceived,: | Pointer to where part's response should be stored. This is the complete response, no filters. |
| u8Size,: | Number of words to send/receive. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaExtractAccelResponse | ( | const uint16_t * | pu16RawResponse, |
| uint16_t * | pu16Response, | ||
| uint8_t | u8Size | ||
| ) |
Extracts 10-bit accel information from raw data.
| pu16RawResponse,: | pointer to 16-bit, unfiltered response. |
| pu16Response,: | pointer to where filtered data should be stored. |
| u8Size,: | Size of raw responses to filter. |
| uint8_t u8fnMirandaExtractRegisterResponse | ( | const uint16_t * | pu16RawResponse, |
| uint16_t * | pu16Response, | ||
| uint8_t | u8Size, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Extracts 8-bit information from raw data.
| pu16RawResponse,: | pointer to 16-bit, unfiltered response. |
| pu8Response,: | pointer to where filtered data should be stored. |
| u8Size,: | Size of raw responses to filter. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaReadAccelRegisters | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Reads accelerations by mean of registers readback.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaReadAccelSPI | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| const uint8_t | cu8Axis, | ||
| uint16_t * | pu16AccelResults | ||
| ) |
Reads acceleration by mean of SPI extraction (Protocol1 only)
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| cu8Axis,: | 1 for X, 2 for Y, 3 for Z. Any other value will result in an X-axis reading. |
| pu16AccelResults,: | Pointer to location where accel reading(s) will be stored. |
| uint8_t u8fnMirandaReadAllRegisters | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Reads all registers content.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaReadRegister | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| uint16_t | u16Register, | ||
| uint16_t * | pu16DataRead, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Reads one register from Miranda.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| u16Register,: | Address of the register to read with LSB in BIT21. For simplicity, use the #defines in this same file. |
| pu16DataRead,: | Pointer to where data read should be stored. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaReset | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Performs a soft-reset of the device.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| cu8Protocol,: | Communication protocol activated. |
| uint8_t u8fnMirandaWriteRegister | ( | const uint8_t | cu8DSPIInstance, |
| const uint8_t | cu8ChipSelect, | ||
| uint16_t | u16Register, | ||
| uint16_t | u16ValueToWrite, | ||
| uint16_t * | pu16DataRead, | ||
| const uint8_t | cu8Protocol | ||
| ) |
Writes to one register of the MMIRANDA.
| cu8DSPIInstance,: | DSPI Instance to use. |
| cu8ChipSelect,: | ChipSelect mask to be used. |
| u16Register,: | Address of the register to write with LSB in BIT21. For simplicity, use the #defines in this same file. |
| u16ValueToWrite,: | 16-bit value to be written to the register. |
| pu8DataRead,: | Pointer to where part's response should be stored. |
| cu8Protocol,: | Communication protocol activated. |
| const uint16_t cau16MirandaPerformAccelReading[] |
{
(MIRANDA_RATE_X | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR),
(MIRANDA_ACC_Y | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR),
(MIRANDA_ACC_Z | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR),
((MIRANDA_RATE_X >> 4u) | ((MIRANDA_READ_REGISTER | 0x80u) << CHAR_BIT)),(CLEAR),
((MIRANDA_ACC_Y >> 4u) | ((MIRANDA_READ_REGISTER | 0x80u) << CHAR_BIT)),(CLEAR),
((MIRANDA_ACC_Z >> 4u) | ((MIRANDA_READ_REGISTER | 0x80u) << CHAR_BIT)),(CLEAR),
(MIRANDA_RATE_X_P2 | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR),
(MIRANDA_ACC_Y_P2 | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR),
(MIRANDA_ACC_Z_P2 | (MIRANDA_READ_REGISTER << CHAR_BIT)),(CLEAR)
}
| const uint16_t cau16MirandaPerformAccelReadingSPI[] |
{
(MIRANDA_READ_ACCEL | MIRANDA_READ_X),(CLEAR),
(MIRANDA_READ_ACCEL | MIRANDA_READ_Y),(CLEAR),
(MIRANDA_READ_ACCEL | MIRANDA_READ_Z),(CLEAR)
}
| const uint16_t cau16MirandaReset[] |
{
(MIRANDA_DEVCTL | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0x0080u),
(MIRANDA_DEVCTL | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0x00C0u),
(MIRANDA_DEVCTL | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0x0040u),
((MIRANDA_DEVCTL >> 4u) | ((MIRANDA_WRITE_REGISTER >> 1u) << CHAR_BIT)),(0x0080u),
((MIRANDA_DEVCTL >> 4u) | ((MIRANDA_WRITE_REGISTER >> 1u) << CHAR_BIT)),(0x00C0u),
((MIRANDA_DEVCTL >> 4u) | ((MIRANDA_WRITE_REGISTER >> 1u) << CHAR_BIT)),(0x0040u),
(MIRANDA_DEVCTL_P2 | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0x8000u),
(MIRANDA_DEVCTL_P2 | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0xC000u),
(MIRANDA_DEVCTL_P2 | (MIRANDA_WRITE_REGISTER << CHAR_BIT)),(0x4000u)
}